import Vue from 'vue'
import Vuex from 'vuex'
import {
  getway
} from '@/api'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    city: '',
    cinema: '',
    filmid: '',
    token:'',
    returnss:'', //暂用的登陆返回值（全部）
    sendfilm:{filmid:'',time:''}    //仅用来从购票（按电影分组）跳转到电影院时使轮播和时间正好匹配
  },
  getters: {

  },
  mutations: {
    changesendfilm(state,obj){
      state.sendfilm.filmid=obj.n
      state.sendfilm.time=obj.t
    },
    changecity(state, n) {
      state.city = n
    },
    changes(state, n) {
      state.cinema = n
    },
    changefilmid(state, n) {
      state.filmid = n
    },
    changetoken(state,n){
      state.token = n
    },
    changereturnss(state,n){
      state.returnss = n
    }
  },
  actions: { //异步获取返回城市影院
    changecinema(cont, t) {
      getway(t).then((resp) => {
        cont.commit('changes', resp)
      })
    }
  },
  modules: {}
})